//
//  KKNetworkRequest.m
//  Questionnaire
//
//  Created by leo on 16/1/24.
//  Copyright © 2016年 leo. All rights reserved.
//

#import "KKNetworkRequest.h"

@implementation KKNetworkRequest

- (instancetype)initWithHost:(NSString*)host {
    return [self initWithHost: host interfaceName: nil parmeters: nil];
}

- (instancetype)initWithHost:(NSString *)host interfaceName:(NSString*)interfaceName {
    return [self initWithHost: host interfaceName: interfaceName parmeters: nil];
}

- (instancetype)initWithHost:(NSString *)host interfaceName:(NSString*)interfaceName parmeters:(NSDictionary*)parmeters {
    self = [super init];
    if (self) {
        _requestHost = host;
        _requestInterfaceName = interfaceName;
        _requestParmeters = parmeters;
    }
    return self;
}

#pragma mark - 

- (NSString*)requestURL {
    
    if (_requestURL == nil) {
        _requestURL = [NSString stringWithFormat: @"%@%@", _requestHost, _requestInterfaceName];
    }
    return _requestURL;
}

- (NSData*)postData {
    return [NSJSONSerialization dataWithJSONObject: self.requestParmeters options: NSJSONWritingPrettyPrinted error: nil];
}

@end
